package com.mdxx.xczd.db.bo;

import android.content.ContentValues;
import android.content.Context;

import com.mdxx.xczd.bean.FileBean;
import com.mdxx.xczd.db.dao.FileServerDAO;
import com.mdxx.xczd.db.dao.ServerDAO;
import com.mdxx.xczd.utils.GsonUtil;

import java.util.List;

public class FileDataBO {

	private ServerDAO serverDAO;

	public FileDataBO(Context context){
		serverDAO = new FileServerDAO(context);
	}
	
	/**
	 * 存位置数据
	 */
	public boolean insertFileData(FileBean fileBean) {
		boolean flag = false;
		String file = GsonUtil.bean2json(fileBean);
		ContentValues values = new ContentValues();
		values.put("file", file);
		flag = serverDAO.add("file", values);
		return flag;
	}

	/**
	 * 查位置数据
	 */
	public List<FileBean> queryFileData() {
		String sql = "select * from file";
		List<FileBean> list = serverDAO.queryMulti(sql);
		return list;
	}

	/**
	 * 删位置数据
	 */
	public void delFileData() {
		String sql = "delete from file";
		serverDAO.delete(sql);
	}	
}
